// 此处存储所有与书目管理相关的请求
import request from '@/utils/request'

// 获取书目数据，支持分页查询 、查询书目
export const getBookData = (pageSize, currentPage, bookName) => {
  return request.get('/book', {
    params: {
      pageSize,
      page: currentPage,
      bookName
    }
  })
}

// 删除书目
export const deleteByid = (ids) => {
  return request.delete('/book', {
    params: {
      ids
    }
  })
}

// 新增书目 没有参数 会返回书目id
export const addBook = (bookForm) => {
  return request.post('/book', bookForm)
}

// 编辑书目 没有参数 不返回书目id
export const editBook = (bookForm) => {
  return request.put('/book', bookForm)
}

// 根据bookId获取该本书的详细信息
export const getBookInf = (id) => {
  return request.get(`/book/${id}`)
}

// /book/catalog 查询这本书有多少个最小单位，为图片录入做准备
export const getBookCatalog = (id, bookName, index) => {
  return request.get('/book/catalog', {
    params: {
      id,
      bookName,
      index
    }
  })
}

// 该卷(最小计数单位)图片地址提交 /book/importPic
export const handleCatalogImgs = (bookId, catalogId, pictureUrl) => {
  return request.post('/book/importPic', {
    bookId,
    catalogId,
    pictureUrl
  })
}
